using System;
using System.Collections.Generic;
using System.Text;

namespace GPSCore
{
    #region SignalToNoiseRatioRating

    /// <summary>
    /// Satallite Signal To Noise Ratio
    /// </summary>
    public enum SignalToNoiseRatioRating
    {
        /// <summary>
        /// 41 or more (dB)
        /// </summary>
        Excellent = 41,
        /// <summary>
        /// 31 - 40 (dB)
        /// </summary>
        Good = 31,
        /// <summary>
        /// 16 - 30 (dB)
        /// </summary>
        Moderate = 16,
        /// <summary>
        /// 1 - 15 (dB)
        /// </summary>
        Poor = 1,
        /// <summary>
        /// No Signal Satallite obscured
        /// </summary>
        None = 0
    }
    
    #endregion

    #region SignalToNoiseRatio

    /// <summary>
    /// Rappresent the Signal to Noise Ration for a Satallite
    /// </summary>
    public class SignalToNoiseRatio
    {
        #region members

        private SignalToNoiseRatioRating _rating;

        private int _value;

        #endregion

        #region constructors

        /// <summary>
        /// Base SignalToNoiseRatio Constructor
        /// </summary>
        public SignalToNoiseRatio()
        {
            _value = 0;
            _updateRating();
        }

        /// <summary>
        /// SignalToNoiseRatio Constructor
        /// </summary>
        /// <param name="value">Signal To Noise Value in dB (int)</param>
        public SignalToNoiseRatio(int value)
        {
            _value = value;
            _updateRating();
        }

        #endregion

        #region properties

        /// <summary>
        /// Signl Rating
        /// </summary>
        public SignalToNoiseRatioRating Rating
        {
            get { return _rating; }
        }

        /// <summary>
        /// Signal To Noise Value (in dB)
        /// </summary>
        public int Value
        {
            get { return _value; }
            set { _value = value; _updateRating(); }
        }

        #endregion

        #region methods

        /// <summary>
        /// update the inner rating...
        /// </summary>
        private void _updateRating()
        {
            if (_value > 40)
            {
                _rating = SignalToNoiseRatioRating.Excellent;
            }
            else if (_value > 30)
            {
                _rating = SignalToNoiseRatioRating.Good;
            }
            else if (_value > 15)
            {
                _rating = SignalToNoiseRatioRating.Moderate;
            }
            else if (_value > 0)
            {
                _rating = SignalToNoiseRatioRating.Poor;
            }
            else
                _rating = SignalToNoiseRatioRating.None;

            //rise an event about "SNR" Changed        
        }

        #endregion
    }
    
    #endregion
}
